#include<iostream>
#include<string>
using namespace std;

class Base {
public:
    int i;
    Base(int x):i(x){}
    void show()
    {
        cout << "Base " << i << endl;
    }
};
class Derived :public Base {
public:
    Derived(int x) :Base(x) {}
};
void fun(Base& bb)
{
    cout << bb.i << endl;
}

int main()
{
    Base b1(200);
    b1.show();
    Derived d1(11);
    b1 = d1;
    b1.show();
    Derived d2(22);
    Base& b2 = d2;
    b2.show();
    Derived d3(33);
    Base* b3 = &d3;
    b3->show();
    Derived d4(77);
    fun(d4);

    return 0;
}


/*
class Data_rec {
protected:
    string name;
    char sex;
    int age;
public:
    Data_rec(string name1, char sex1, int age1)
    {
        name = name1;
        sex = sex1;
        age = age1;
    }
};
class Student :virtual public Data_rec {
protected:
    string major;
    double score;
public:
    Student(string name1, char sex1, int age1, string major1, double score1) :Data_rec(name1, sex1, age1)
    {
        major = major1;
        score = score1;
    }
};
class Employee :virtual public Data_rec{
protected:
    string dept;
    double salary;
public:
    Employee(string name1, char sex1, int age1, string dept1, double salary1) :Data_rec(name1, sex1, age1) {
        dept = dept1;
        salary = salary1;
    }

};
class E_Student :public Employee, public Student {
public:
    E_Student(string name1, char sex1, int age1, string major1, double score1, string dept1, double salary1) :Data_rec(name1, sex1, age1), Student(name1, sex1, age1, major1, score1) ,
    Employee(name1,sex1,age1,dept1,salary1){
    }
    void print()
    {
        cout << "name:" << name << endl;
        cout << "sex:" << sex << endl;
        cout << "age:" << age << endl;
        cout << "score:" << score << endl;
        cout << "major:" << major << endl;
        cout << "dept:" << dept << endl;
        cout << "salary:" << salary << endl;
    }
 };
int main()
{
    E_Student my_E_Student("WangYue", 'f', 35, "Computer", 95, "Teaching Affaires Office", 3500);
    my_E_Student.print();

    return 0;
}

class Base{
private:
    int a;
public:
    Base(int sa)
    {
        a=sa;
        cout<<"Constructing Base"<<endl;
    }
};
class Base1:virtual public Base{
private:
    int b;
public:
    Base1(int sa,int sb):Base(sa)
    {
        b=sb;
        cout<<"Constructing Base1"<<endl;
    }
};
class Base2:virtual public Base{
private:
    int c;
public:
    Base2(int sa,int sc):Base(sa)
    {
        c=sc;
        cout<<"Constructing Base2"<<endl;
    }
};
class Derived:public Base1,public Base2{
private:
    int d;
public:
    Derived(int sa,int sb,int sc,int sd):Base(sa),Base1(sa,sb),Base2(sa,sc)
    {
        d=sd;
        cout<<"Constructing Derived"<<endl;
    }
};

int main()
{
    Derived obj(2,4,6,8);
        
    return 0;
}


class Base{
protected:
    int a;
public: 
    Base()
    {
        a=5;
        cout<<"Base a="<<a<<endl;
    }
};
class Base1:virtual public Base{
public:
    int b1;
    Base1()
    {
        a=a+10;
        cout<<"Base1 a="<<a<<endl;
    }
};
class Base2:virtual public Base{
public:
    int b2;
    Base2()
    {
        a=a+20;
        cout<<"Base2 a="<<a<<endl;
    }
};
class Derived:public Base1,public Base2{
public:
    int d;
    Derived()
    {
        cout<<"Dervied a="<<a<<endl;
    }
};


int main()
{
    Derived obj;
        
    return 0;
}

class Base{
protected:
    int a;
public:
    Base()
    {
        a=5;
        cout<<"Base a="<<a<<endl;
    }
};
class Base1:public Base{
public:
    int b1;
    Base1()
    {
        a=a+10;
        cout<<"Base1 a="<<a<<endl;
    }
};
class Base2:public Base{
public:
    int b2;
    Base2()
    {
        a=a+20;
        cout<<"Base2 a="<<a<<endl;
    }
};
class Derived:public Base1,public Base2{
public:
    int d;
    Derived()
    {
        cout<<"Base1::a="<<Base1::a<<endl;
        cout<<"Base2::a="<<Base2::a<<endl;
    }
};

int main()
{
    Derived obj;
    return 0;
}


class X{
private:
    int a;
public:
    X(int sa)
    {
        a=sa;
        cout<<"Constructing class X."<<endl;
    }
    int getX()
    {
        return a;
    }
    ~X()
    {
        cout<<"Destructing class X."<<endl;
    }
};
class Y{
private:
    int b;
public:
    Y(int sb)
    {
        cout<<"Constructing class Y."<<endl;
        b=sb;
    }
    int getY()
    {
        return b;
    }
    ~Y()
    {
        cout<<"Destructing class Y."<<endl;
    }
};

class Z:public X,private Y{
private:
    int c;
public:
    Z(int sa,int sb,int sc):X(sa),Y(sb)
    {
        cout<<"Constructing class Z."<<endl;
        c=sc;
    }
    int getZ()
    {
        return c;
    }
    int getY()
    {
        return Y::getY();
    }
    ~Z()
    {
        cout<<"Destructing class Z."<<endl;
    }
};
int main()
{
    Z obj(2,4,6);
    int ma=obj.getX();
    cout<<"a="<<ma<<endl;
    int mb=obj.getY();
    cout<<"b="<<mb<<endl;
    int mc=obj.getZ();
    cout<<"c="<<mc<<endl;
    return 0;
} 

class X{
private:
    int a;
public:
    void setX(int x)
    {
        a=x;
    }
    void showX()
    {
        cout<<"a="<<a<<endl;
    }
};
class Y{
private:
    int b;
public:
    void setY(int x)
    {
        b=x;
    }
    void showY()
    {
        cout<<"b="<<b<<endl;
    }
};
class Z:public X,private Y{
private:
    int c;
public:
    Y::showY;
    Y::setY;
    void setZ(int x,int y)
    {
        c=x;
        setY(y);
    }
    void showZ()
    {
        showY();
        cout<<"c="<<c<<endl;
    }
};

int main()
{
    Z obj;
    obj.setX(3);
    obj.showX();
    obj.setY(4);
    obj.showY();
    obj.setZ(6,8);
    obj.showZ();
        
    return 0;
} 
class A{
private:
    int x;
public:
    A(int x1)
    {
        x=x1;
    }
    void print()
    {
        cout<<"x="<<x<<endl;
    }
};
class B:private A{
private:
    int y;
public:
    B(int x1,int y1):A(x1)
    {
        y=y1;
    }
    A::print;
};

int main()
{
    B b(10,20);
    b.print();
        
    return 0;
} 

class Student{
protected:
    int number;
    string name;
    float score;
public:
    Student(int number1,string name1,float score1)
    {
        number=number1;
        name=name1;
        score=score1;
    }
    void print()
    {
        cout<<"number:"<<number<<endl;
        cout<<"name:"<<name<<endl;
        cout<<"score:"<<score<<endl;
    }
};

class UStudent:private Student{
private:
    string major;
public:
    UStudent(int number1,string name1,float score1,string major1):Student(number1,name1,score1)
    {
        major=major1;
    }
    void print()
    {
        Student::print();
        cout<<"major:"<<major<<endl;
    }
};

int main()
{
    UStudent stu(22116,"Zhang Zhi",95,"Computer Science");
    stu.print();
        
    return 0;
}

class Student{
protected:
    int number;
    string name;
    float score;
public:
    Student(int number1,string name1,float score1)
    {
        number=number1;
        name=name1;
        score=score1;
    }
    void print()
    {
        cout<<"No:"<<number<<endl;
        cout<<"Name:"<<name<<endl;
        cout<<"Score:"<<score<<endl;
    }

};

class UStudent:public Student{
private:
    string major;
    Student auditor1;
    Student auditor2;
public:
    UStudent(int number1,string name1,float score1,int number2,string name2,float score2,int number3,string name3,float score3,string major1):Student(number1,name1,score1),auditor1(number2,name2,score2),auditor2(number3,name3,score3)
    {
        major=major1;
    }
    void print()
    {
        cout<<"Student:"<<endl;
        Student::print();
        cout<<"Major:"<<major<<endl;
    }
    void print_auditor1()
    {
        cout<<"auditor:"<<endl;
        auditor1.print();
        
    }
    void print_auditor2()
    {
        cout<<"auditor:"<<endl;
        auditor2.print();
    }
};

int main()
{
    UStudent stu(2001,"Zhang_Zhi",95,3001,"Wang_Da",70,3002,"Li_San",76,"IOT Engineering");
    stu.print();
    stu.print_auditor1();
    stu.print_auditor2(); 
        
    return 0;
} */